<template>
  <div style="width:80%;margin:0 auto">
    <!-- 全球公司 -->
    <div class="title">全球公司</div>
    <el-card shadow="always">
      <el-form  label-width="140px" style="width: 80%; margin: 0 auto">
				<el-form-item style="border-bottom: 1px solid #ebeef5" label-width="0px">
					<el-form-item label="公司类型：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list1.companyType==0" value="孵化公司" type="text" readonly />
            <input style="width:100%" v-else-if="list1.companyType==1" value="临时公司" type="text" readonly />
            <input style="width:100%" v-else-if="list1.companyType==2" value="正式公司" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
					<el-form-item label="公司名称：" style="width: 50%; display: inline-block">
						<input style="width:100%" v-if="list1.companyName" v-model="list1.companyName" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
          <el-form-item label="" style="width: 10%; display: inline-block">
						<el-button v-if="list1.isTrue" size="mini" type="primary" @click="handleCompanyForm(list1)">查看详情</el-button>
            <el-button v-else size="mini" type="primary" disabled>查看详情</el-button>
					</el-form-item>
				</el-form-item>
        <el-form-item style="border-bottom: 1px solid #ebeef5" label-width="0px">
					<el-form-item label="创始人：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list1.creatorAccount" v-model="list1.creatorAccount" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
					<el-form-item label="合伙人公司名称：" style="width: 40%; display: inline-block">
						<input style="width:100%"  v-if="list1.creatorEnterpriseName" v-model="list1.creatorEnterpriseName" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
				</el-form-item>
        <el-form-item style="border-bottom: 1px solid #ebeef5" label-width="0px">
					<el-form-item label="首席合伙人：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list1.chiefPartnerAccount" v-model="list1.chiefPartnerAccount" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
					<el-form-item label="合伙人公司名称：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list1.chiefPartnerName" v-model="list1.chiefPartnerName" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
				</el-form-item>
			</el-form>
    </el-card>
    <!-- 省级公司 -->
    <div class="title">省级公司</div>
    <el-card shadow="always">
      <el-form  label-width="140px" style="width: 80%; margin: 0 auto">
				<el-form-item style="border-bottom: 1px solid #ebeef5" label-width="0px">
					<el-form-item label="公司类型：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list2.companyType==0" value="孵化公司" type="text" readonly />
            <input style="width:100%" v-else-if="list2.companyType==1" value="临时公司" type="text" readonly />
            <input style="width:100%" v-else-if="list2.companyType==2" value="正式公司" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
					<el-form-item label="公司名称：" style="width: 50%; display: inline-block">
						<input style="width:100%" v-if="list2.companyName" v-model="list2.companyName" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
          <el-form-item label="" style="width: 10%; display: inline-block">
						<el-button v-if="list2.isTrue" size="mini" type="primary" @click="handleCompanyForm(list2)">查看详情</el-button>
            <el-button v-else size="mini" type="primary" disabled>查看详情</el-button>
					</el-form-item>
				</el-form-item>
        <el-form-item style="border-bottom: 1px solid #ebeef5" label-width="0px">
					<el-form-item label="创始人：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list2.creatorAccount" v-model="list2.creatorAccount" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
					<el-form-item label="合伙人公司名称：" style="width: 40%; display: inline-block">
						<input style="width:100%"  v-if="list2.creatorEnterpriseName" v-model="list2.creatorEnterpriseName" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
				</el-form-item>
        <el-form-item style="border-bottom: 1px solid #ebeef5" label-width="0px">
					<el-form-item label="首席合伙人：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list2.chiefPartnerAccount" v-model="list2.chiefPartnerAccount" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
					<el-form-item label="合伙人公司名称：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list2.chiefPartnerName" v-model="list2.chiefPartnerName" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
				</el-form-item>
        <el-form-item label="" label-width="0px">
					<el-form-item label="" style="width: 100%;text-align:right">
						<el-button v-if="list2.isTrue && list2.companyType==2 && !list2.chiefPartnerAccount" size="mini" type="danger" @click="toPartnerChange(list2)">首席合伙人变更</el-button>
            <el-button v-else size="mini" type="danger" disabled>首席合伙人变更</el-button>
					</el-form-item>
				</el-form-item>
			</el-form>
    </el-card> 
      <!-- 市级公司 -->
    <div class="title">市级公司</div>
    <el-card shadow="always">
     <el-form  label-width="140px" style="width: 80%; margin: 0 auto">
				<el-form-item style="border-bottom: 1px solid #ebeef5" label-width="0px">
					<el-form-item label="公司类型：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list3.companyType==0" value="孵化公司" type="text" readonly />
            <input style="width:100%" v-else-if="list3.companyType==1" value="临时公司" type="text" readonly />
            <input style="width:100%" v-else-if="list3.companyType==2" value="正式公司" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
					<el-form-item label="公司名称：" style="width: 50%; display: inline-block">
						<input style="width:100%" v-if="list3.companyName" v-model="list3.companyName" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
          <el-form-item label="" style="width: 10%; display: inline-block">
						<el-button v-if="list3.isTrue" size="mini" type="primary" @click="handleCompanyForm(list3)">查看详情</el-button>
            <el-button v-else size="mini" type="primary" disabled>查看详情</el-button>
					</el-form-item>
				</el-form-item>
        <el-form-item style="border-bottom: 1px solid #ebeef5" label-width="0px">
					<el-form-item label="创始人：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list3.creatorAccount" v-model="list3.creatorAccount" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
					<el-form-item label="合伙人公司名称：" style="width: 40%; display: inline-block">
						<input style="width:100%"  v-if="list3.creatorEnterpriseName" v-model="list3.creatorEnterpriseName" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
				</el-form-item>
        <el-form-item style="border-bottom: 1px solid #ebeef5" label-width="0px">
					<el-form-item label="首席合伙人：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list3.chiefPartnerAccount" v-model="list3.chiefPartnerAccount" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
					<el-form-item label="合伙人公司名称：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list3.chiefPartnerName" v-model="list3.chiefPartnerName" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
				</el-form-item>
        <el-form-item label="" label-width="0px">
					<el-form-item label="" style="width: 100%;text-align:right">
						<el-button v-if="list3.isTrue && list3.companyType==2 && !list3.chiefPartnerAccount" size="mini" type="danger" @click="toPartnerChange(list3)">首席合伙人变更</el-button>
            <el-button v-else size="mini" type="danger" disabled>首席合伙人变更</el-button>
					</el-form-item>
				</el-form-item>
			</el-form>
    </el-card>  
      <!-- 县级公司 -->
    <div class="title">县级公司</div>
    <el-card shadow="always">
      <el-form  label-width="140px" style="width: 80%; margin: 0 auto">
				<el-form-item style="border-bottom: 1px solid #ebeef5" label-width="0px">
					<el-form-item label="公司类型：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list4.companyType==0" value="孵化公司" type="text" readonly />
            <input style="width:100%" v-else-if="list4.companyType==1" value="临时公司" type="text" readonly />
            <input style="width:100%" v-else-if="list4.companyType==2" value="正式公司" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
					<el-form-item label="公司名称：" style="width: 50%; display: inline-block">
						<input style="width:100%" v-if="list4.companyName" v-model="list4.companyName" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
          <el-form-item label="" style="width: 10%; display: inline-block">
						<el-button v-if="list4.isTrue" size="mini" type="primary" @click="handleCompanyForm(list4)">查看详情</el-button>
            <el-button v-else size="mini" type="primary" disabled>查看详情</el-button>
					</el-form-item>
				</el-form-item>
        <el-form-item style="border-bottom: 1px solid #ebeef5" label-width="0px">
					<el-form-item label="创始人：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list4.creatorAccount" v-model="list4.creatorAccount" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
					<el-form-item label="合伙人公司名称：" style="width: 40%; display: inline-block">
						<input style="width:100%"  v-if="list4.creatorEnterpriseName" v-model="list4.creatorEnterpriseName" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
				</el-form-item>
        <el-form-item style="border-bottom: 1px solid #ebeef5" label-width="0px">
					<el-form-item label="首席合伙人：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list4.chiefPartnerAccount" v-model="list4.chiefPartnerAccount" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
					<el-form-item label="合伙人公司名称：" style="width: 40%; display: inline-block">
						<input style="width:100%" v-if="list4.chiefPartnerName" v-model="list4.chiefPartnerName" type="text" readonly />
            <input style="width:100%" v-else value="无" type="text" readonly />
					</el-form-item>
				</el-form-item>
        <el-form-item label="" label-width="0px">
					<el-form-item label="" style="width: 100%;text-align:right">
            <!-- <el-button  size="mini" type="danger" @click="toPartnerChange(list4)">首席合伙人变更</el-button> -->
						<el-button v-if="list4.isTrue && list4.companyType!=0" size="mini" type="danger" @click="toPartnerChange(list4)">首席合伙人变更</el-button>
            <el-button v-else size="mini" type="danger" disabled>首席合伙人变更</el-button>
					</el-form-item>
				</el-form-item>
			</el-form>
    </el-card>
    <!--公司详情-->
        <el-dialog
            title="公司信息"
            :visible.sync="companyVisible"
            :before-close="hideCompanyForm"
            width="50%"
            top="5vh"
            v-dialogDrag
            :close-on-click-modal="false"
        >
        <template slot="title">
            <div class="avue-crud__dialog__header">
                <span class="el-dialog__title">
                <span style="display:inline-block;background-color: #3478f5;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px"></span>
                公司信息
                </span>
            </div>
        </template>
        <el-card>
            <el-form >
                <el-form-item label-width="80px" label="基本信息" style="background: #e1e1e1"/>
                <el-form-item label-width="40px">
                    <el-form-item label-width="100px" label="发起合伙人：" style="width:50%;display: inline-block;">
                        <span>{{company.initiatingpartnername}}</span>
                    </el-form-item>
                    <el-form-item label="首席合伙人：" style=" margin-left: 20px; width:30%;display: inline-block;">
                        <span>{{company.chiefpartnername}}</span>
                        <span v-if="company.isincubate==1">(孵化)</span>
                        <span v-if="company.isdisplacement==1">(顶替)</span>
                    </el-form-item>
                </el-form-item>

                <el-form-item label-width="100px" label="高级合伙人" style="background: #e1e1e1"/>
                <el-form-item>
                    <el-table
                        :data="seniorpartner"
                        :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
                        border
                    >
                        <el-table-column label="序号"  type="index"  width="80"  align="center">
                            <template scope="scope">
                                <span>{{scope.$index + 1}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="usernick" align="center" label="用户昵称" />
                        <el-table-column prop="usermobile" align="center" label="手机号" />
                        <el-table-column prop="registrationnumber" align="center" label="营业执照" />
                    </el-table>
                </el-form-item>

                <el-form-item label-width="100px" label="普通合伙人" style="background: #e1e1e1"/>
                <el-form-item>
                    <el-table
                        :data="generalpartner"
                        :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
                        border
                    >
                        <el-table-column label="序号"  type="index"  width="80"  align="center">
                            <template scope="scope">
                                <span>{{scope.$index + 1}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="usernick" align="center" label="用户昵称" />
                        <el-table-column prop="usermobile" align="center" label="手机号" />
                        <el-table-column prop="registrationnumber" align="center" label="营业执照" />
                    </el-table>
                </el-form-item>
            </el-form>
        </el-card>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="hideCompanyForm">取消</el-button>
            </div>
        </el-dialog>
  </div> 
</template>
<script>
import {
        getCreateCompanyList,
        getCompanyDetails
    } from "../../../api/activityCommodity/activityCommodity.js";
export default {
  components: {},
  data() {
    return {
         activeName: 'first',//选项卡默认选择
         formData:{
           enterprisename:"孵化xxxxxxxxxx",
           usermobile:'xxxxxxxxxxxxxxxxxxx'
         },
         companyVisible:false,
         launchcompany:"",
         company:{},
         seniorpartner:[],
         generalpartner:[],
         list1:{},
         list2:{},
         list3:{},
         list4:{},
    };
  },
  methods: {
    toPartnerChange(obj){
      this.$router.push({
        path:"partnerChange",
        query:obj
      })
    },
    hideCompanyForm(){
      this.companyVisible=false;
      this.launchcompany="";
      this.company={};
      this.seniorpartner=[];
      this.generalpartner=[];
    },
    handleCompanyForm(val){
      this.companyVisible=true;
      let query={
          companyid:val.companyId
      }
      getCompanyDetails(query)
      .then(response => {
          if (response.code != 0) {
              this.$message.error(response.message);
              return false;
          }
          this.launchcompany=response.data.initiatingCompany;
          this.company=response.data.company;
          this.seniorpartner=response.data.seniorPartner;
          this.generalpartner=response.data.generalPartner;
          this.companyVisible=true;
      })
    },
    getCreateCompanyList(){
      getCreateCompanyList()
      .then(response => {
          if (response.code != 0) {
              this.$message.error(response.message);
              return false;
          }
          if(response.data.list1.length<=0){
            response.data.list1 = [{isTrue:false}]
          }else{
            response.data.list1[0].isTrue=true
          }
          if(response.data.list2.length<=0){
            response.data.list2 = [{isTrue:false}]
          }else{
            response.data.list2[0].isTrue=true
          }
          if(response.data.list3.length<=0){
            response.data.list3 = [{isTrue:false}]
          }else{
            response.data.list3[0].isTrue=true
          }
          if(response.data.list4.length<=0){
            response.data.list4 = [{isTrue:false}]
          }else{
            response.data.list4[0].isTrue=true
          }
          this.list1 = response.data.list1[0]
          this.list2 = response.data.list2[0]
          this.list3 = response.data.list3[0]
          this.list4 = response.data.list4[0]
      })
    }
  },
  mounted(){
   
  },
  created() {
     this.getCreateCompanyList()
    // console.log(this.$store.state)
  },
};
</script>
<style lang="scss"  scoped>
.title{
  font-size: 24px;
    font-weight: bold;
    margin: 20px 0;
}
</style>
